package com.tanhua.model.vo;

import com.tanhua.model.domain.Announcement;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Announcementvo  implements Serializable{
    private String id;
    private String title;
    private String description;
    private String createDate;

    public static Announcementvo init(Announcement announcement){
        Announcementvo vo = new Announcementvo();
        BeanUtils.copyProperties(announcement,vo);
        Date date = new Date(announcement.getCreated().getTime());
        vo.setCreateDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date));
        vo.setId(announcement.getId().toString());
        return vo;

    }
}
